package com.atguigu.gulimall.order.vo;

import io.prometheus.client.Summary;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Member;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: BlueSky
 * @create: 2021-09-30 09:16
 **/


public class OrderConfirmVo {

	//收货地址，ums_member_receive_address表
	@Getter @Setter
	List<MemberAddressVo> addressVos;

	//所有选中的购物项
	@Getter @Setter
	List<OrderItemVo> items;

	//发票信息...

	// 优惠信息...
	@Getter @Setter
	Integer integeration;

	@Getter @Setter
	Map<Long,Boolean> stocks;

	@Setter @Getter
	String orderToken;	//防重复提交令牌

	// BigDecimal total;//订单总额
	public BigDecimal getTotal(){
		BigDecimal sum = new BigDecimal("0");
		if (items!=null){
			for (OrderItemVo item : items) {
				BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
				sum = sum.add(multiply);
			}
		}
		return sum;
	}

	// BigDecimal payPrice;//应付价格
	public BigDecimal getPayPrice(){
		return getTotal();
	}

}

